<?php

namespace app\api\controller;

use app\api\mdl\MdlAccept;
use lib\libTool;
use lib\libUploader;
use lib\libVar;
use think\facade\Config;

class Api
{
    //图片上传
    public function uploaderBase64V2()
    {
        $base64Image = libVar::param("image_path")->toString();
        $fileHz = libVar::param("file_hz")->toString();
        $option = [
            "filePath"     => $base64Image,
            "savePath"     => "uploadfile/notice",
            "isFormUpload" => FALSE,
            "isBase64"     => 2,//是否是base64上传,仅针对图片上传
            "fileHz"       => $fileHz,//图片文件路径
            "prefix"       => 'admin_'//文件名称前缀
        ];
        $obj = new libUploader($option);
        $res = $obj->upload();
        $code = $res['code'];
        $msg = $res['msg'];
        $info = $obj->getFileInfo();
        return json([
            "code" => $code,
            "msg"  => $msg,
            "data" => $info['fileSaveName'],
            "url"  => \tool\Url::FileConversionUrl($info['fileSaveName'])
        ]);
    }
}